<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class HelpAnswer extends Model
{

    protected $fillable = [
        'help_request_id',
        'user_id',
        'answer_content',
        'is_ai_generated',
        'upvotes_count',
        'is_best_answer',
        'is_hidden'
    ];

    protected $casts = [
        'is_ai_generated' => 'boolean',
        'upvotes_count' => 'integer',
        'is_best_answer' => 'boolean',
        'is_hidden' => 'boolean',
        'created_at' => 'datetime'
    ];

    /**
     * 关联用户
     */
    public function user()
    {
        return $this->belongsTo(User::class);
    }

    /**
     * 关联求助请求
     */
    public function helpRequest()
    {
        return $this->belongsTo(HelpRequest::class);
    }
}